package com.fileuptool.service;

import java.io.File;
import java.io.InputStream;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
/**
 * 
 *@author dinghao
* @ClassName: FileUpService 
* @Description: TODO
* @date 2018年3月15日 下午4:40:53 
*
 */
@Service
public class FileUpService {

	public boolean writeFile(MultipartFile file) throws Exception {
		String originalFilename = file.getOriginalFilename();
		InputStream inputStream = file.getInputStream();
		File tempFile = new File("F:\\tempFile\\"+originalFilename);
		try {
			FileUtils.copyInputStreamToFile(inputStream, tempFile);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;		
		}
		
	}
}
